package shuiyuqing.views.adapters;

import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.xkh.xkh.R;

import java.util.ArrayList;

import com.xkh.xkh.MyApplication;
import shuiyuqing.model.BasicInfoModel;
import shuiyuqing.network.beans.IrrBAWaterGate;
import shuiyuqing.network.beans.IrrBTCanalDetail;

/**
 * 选择闸门
 * Created by 凯 on 2015/11/7.
 */
@Deprecated
public class ChooseWaterGateAdapter extends BaseAdapter{

    // 选中的渠道
    IrrBTCanalDetail detail;


    // 获取到闸门
    ArrayList<IrrBAWaterGate> waterGates;

    // 设置所在渠道
    public void setDetail(IrrBTCanalDetail detail) {
        this.detail = detail;
        if (detail != null)
        {
            waterGates = (ArrayList<IrrBAWaterGate>) BasicInfoModel.getGatesByCannal(detail.getCanalCode());
        }else
        {
            waterGates = (ArrayList<IrrBAWaterGate>) BasicInfoModel.getAllGate();
        }

    }


    @Override
    public int getCount() {
        return waterGates.size();
    }

    @Override
    public Object getItem(int position) {
        return waterGates.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {

        IrrBAWaterGate gate = waterGates.get(position);

        convertView = View.inflate(MyApplication.share(),R.layout.item_watergate,null);
        TextView tv_waterGateName = (TextView) convertView.findViewById(R.id.id_tv_waterGateName);
        tv_waterGateName.setText(gate.getWatergateName());

        convertView.setTag(R.id.id_gate,gate);

        return convertView;
    }
}
